package com.szxy;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author: zwz
 * @Date:2020/7/14 20:26
 * @Description:com.szxy
 * @Version:1.0
 **/
@SpringBootApplication
@EnableDiscoveryClient
@RestController
public class SentinelProviderApplication {

    /**
     * 程序入口
     *
     * @param args
     */
    public static void main(String[] args) {
        SpringApplication.run(SentinelProviderApplication.class, args);
    }

    /**
     * 测试
     *
     * @return
     */
    @GetMapping("/test")
    public ResponseEntity<String> test() {
        return ResponseEntity.ok("Hello ， 我是 sentinel-provider");
    }

    /**
     * 购买商品
     * @param name
     * @param count
     * @return
     */
    @GetMapping("/goods/buy/{name}/{count}")
    public ResponseEntity<String> buy(@PathVariable("name") String name, @PathVariable("count") Integer count) {
        return ResponseEntity.ok(String.format("购买%d 份%s", count, name));
    }
}
